<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <p class="p1">这是标签1</p>
        <p>这是标签2</p>
        <p>这是标签3</p>
    </div>
</body>
<script>
    //创建节点
    let element = document.createElement('h3')
    //插入节点
    element.innerHTML = "创建的第一个新节点"
    let div = document.querySelector("div");
    div.appendChild(element);

    //insertBefore
    let new_node = document.createElement('p1')
    new_node.innerHTML = "这是新的p标签"
    div.insertBefore(new_node, document.querySelector('.p1'))
</script>

</html>